
from naoqi import *
import time

class RecordWavModule(ALModule):
    
    def __init__( self, strName, IP):
        ALModule.__init__(self, strName);
        self.Ip = IP
        self.ALAudioRecProxy = ALProxy("ALAudioRecorder", IP, 9559)
        
        self.channels =[]
        self.initChannels()
      
        
    def initChannels(self):
        self.channels.append(False) #Left
        self.channels.append(False) #Right
        self.channels.append(True) #Front
        self.channels.append(False) #Rear
             
    def recordWav(self, recordTime=1):
        self.ALAudioRecProxy.startMicrophonesRecording("/home/nao/istu_seiso_48kHz_1kanava2.wav", "wav", 48000, self.channels);
        time.sleep(recordTime)
        self.ALAudioRecProxy.stopMicrophonesRecording()
        
        
if __name__ == '__main__':
    IP= "10.100.52.139"
    # Creation of a new Python Broker
    pythonBroker = ALBroker("pythonBroker","0.0.0.0",9999, IP,9559)
    
    recordModule = RecordWavModule("MySoundProcessingModule", IP)
    recordModule.recordWav(5)
    
    pythonBroker.shutdown()
        
        
        
        
        
        
      
        
